package com.ccp.dev.extend.controller;

import com.ccp.dev.core.basic.annotion.Action;
import com.ccp.dev.core.basic.consts.UrlConstants;
import com.ccp.dev.core.basic.internationalization.SysBaseController;
import com.ccp.dev.core.basic.model.SysAuditModelType;
import com.ccp.dev.core.basic.response.ResultData;
import com.ccp.dev.core.util.RequestUtil;
import com.ccp.dev.core.util.StringUtil;
import com.ccp.dev.core.util.log.SysAuditThreadLocalHolder;
import com.ccp.dev.workflow.model.ProcessRun;
import com.ccp.dev.workflow.model.TaskOpinion;
import com.ccp.dev.workflow.service.ProcessRunService;
import com.ccp.dev.workflow.service.TaskOpinionService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * ClassDescribe:流程任务审批意见控制器类
 * @author :jiayueqiao
 * Date: 2019-08-13
 * Since:1
 */
@Controller
@RequestMapping(UrlConstants.PROJECT_ROOT +"/extend/taskOpinion")
@Action(ownermodel=SysAuditModelType.PROCESS_CENTER)
public class ExtendTaskOpinionController extends SysBaseController {

    @Resource
    private TaskOpinionService taskOpinionService;
    @Resource
    private ProcessRunService processRunService;

    /**
     * 流程审批历史页面
     * @param request request
     * @param model 视图模型
     * @return 页面地址
     */
    @RequestMapping(UrlConstants.VIEW_DISPATCH_PREFIX+UrlConstants.MODULE_FUNCTION_LIST)
    @Action(description = "流程审批历史页面")
    public String viewList(HttpServletRequest request, Model model) {
        String runId = RequestUtil.getString(request,"runId");
        if(StringUtil.isNotEmpty(runId)){
            ProcessRun processRun=processRunService.getById(runId);
            if(null!=processRun){
                model.addAttribute("processRun",processRun);
            }
        }
        return "taskOpinion/list";
    }

}
